package com.pomr.model.synthesize;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pomr.model.sys.Agency;
import com.pomr.model.sys.User;

/**
 * 厂商联系人 依附厂商存在 如果厂商删除会跟随删除
 * @author Administrator
 *
 */
@Entity
@Table(name="linkman")
public class Linkman implements Serializable{
	public String getAgencyName() {
		return agencyName;
	}

	public void setAgencyName(String agencyName) {
		this.agencyName = agencyName;
	}

	public Agency getAgency() {
		return agency;
	}

	public void setAgency(Agency agency) {
		this.agency = agency;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getJob() {
		return job;
	}

	public void setJob(String job) {
		this.job = job;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Integer getManufacturerId() {
		return manufacturerId;
	}

	public void setManufacturerId(Integer manufacturerId) {
		this.manufacturerId = manufacturerId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
    @GenericGenerator(name = "native", strategy = "native")//AUTO 在mysql中需要指定使用本地策略生成主键值
	private Integer id;//	主键
	@Column(name="name",length=20)
	private String name;//姓名
	@Column(name="tel",length=20)
	private String tel;//电话
	@Column(name="remark",length=100)
	private String remark;//备注
	@Column(name="job",length=20)
	private String job;//职务
	@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss") 
	@Column(name="create_time")
	private Date createTime;//创建时间
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="createuser_id")
	private User user;//创建人
	
	@Column(name="manufacturer_id")
	private Integer manufacturerId;
	
	@Formula("(select u.name from user u where u.id=createuser_id)")
	private String userName;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="agency_id")
	private Agency agency;//所属机构
	
	@Formula("(select a.name from agency a where a.id=agency_id)")
	private String agencyName;

}
